package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Title  string  `gorm:"type:varchar(30);not null;comment:商品名称"`
	Image  string  `gorm:"type:varchar(200);not null;comment:商品图片"`
	Price  float64 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	Num    int     `gorm:"type:int(11);not null;comment:商品数量"`
	Status int     `gorm:"type:int;default:1;comment:0 未上架 1已上架"`
}

func (g *Goods) Create() error {
	return DB.Debug().Create(&g).Error
}
func (g *Goods) GetGoodsById() error {
	return DB.Debug().Where("id = ?", g.ID).First(&g).Error
}
